Allow asynchronous callbacks for AsyncRetrying parameters#363
Allow asynchronous callbacks for AsyncRetrying parameters#363
Conversation
13657ee to
f65ca57
Compare
jd
left a comment
There was a problem hiding this comment.
Could we try to DRY the iter method? I understand we need to re-define it but it'd be great if we could share most of the code.
| return await func(retry_state) | ||
| return func(retry_state) | ||
|
|
||
| async def iter(self, retry_state: "RetryCallState") -> typing.Union[DoAttempt, DoSleep, typing.Any]: # noqa |
There was a problem hiding this comment.
@jd I also wanted to use some base method to avoid re-defining the iter method again, however, one of them is sync def iter and other one is async async def iter. Any ideas how to make it DRY?
I wanted to use handle_custom_function to handle sync/async calls, however, if we make handle_custom_function sync function, then it might need to use asyncio.get_event_loop() to run awaitable functions (running async functions from sync function).
There was a problem hiding this comment.
@jd any ideas? I would love to have a progress with this PR and start using async callbacks for retry_error_callback
This change will allow both async and sync functions to be used as callable parameters for Async retries.
Docs are not updated, please, inform if any other changes are needed. Thank you very much for your review.
Fixes #249